﻿using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.JSON;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;

namespace WSDZ.KM.ZH.CreditFileToCreditSearch
{
    [Description("临时信用档案跳转信用查询"), HotUpdate]
    public class ToCreditSearch : AbstractDynamicFormPlugIn
    {
        public string btype = "临时信用档案跳转信用查询";
        public override void AfterEntryBarItemClick(AfterBarItemClickEventArgs e)
        {
            base.AfterEntryBarItemClick(e);
            if (e.BarItemKey.EqualsV1("btnToCreditSearch"))
            {
                try
                {
                    List<string> msgList = new List<string>();
                    //var entity = this.View.BusinessInfo.GetEntryEntity("FEntity");
                    //DynamicObjectCollection datas = this.Model.GetEntityDataObject(entity);

                    int selectRowIndex = this.View.Model.GetEntryCurrentRowIndex("FEntity");
                    EntryEntity data = this.View.BusinessInfo.GetEntryEntity("FEntity");
                    DynamicObject selectRowData = this.View.Model.GetEntityDataObject(data, selectRowIndex);
                    if (selectRowData == null)
                        return;
                    int custId = selectRowData["ObjectId_Id"].ToStringV1().ToInt32V1();
                    if (custId!=0)
                    {

                        //DynamicFormShowParameter formPara = new DynamicFormShowParameter();
                        ////formPara.FormId = "CRE_Rpt_CreditInfo";
                        //formPara.FormId = "CRE_Rpt_CreditInfoFilter";
                        ////formPara.OpenStyle.OpenType = OpenType.MainMenuOpen;
                        //formPara.OpenStyle.ShowType = ShowType.Modal;
                        ////formPara.CustomParams.Add("custId", custId.ToStringV1());
                        ////this.View.ShowForm(formPara, delegate (FormResult result)
                        ////{
                        ////});
                        ////formPara.ParentPageId= this.View.PageId;
                        //View.ShowForm(formPara);


                        SysReportShowParameter sqlParameter = new SysReportShowParameter();
                        sqlParameter.FormId = "CRE_Rpt_CreditInfo";
                        sqlParameter.CustomParams.Add("custId", custId.ToStringV1());
                        sqlParameter.OpenStyle.ShowType = ShowType.Modal;
                        this.View.ShowForm(sqlParameter);

                        //SysReportShowParameter sqlParameter = new SysReportShowParameter();
                        //sqlParameter.FormId = "CRE_Rpt_CreditInfoFilter";
                        //sqlParameter.CustomParams.Add("custId", custId.ToStringV1());
                        //sqlParameter.OpenStyle.ShowType = ShowType.Modal;
                        //this.View.ShowForm(sqlParameter);



                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
   

    }
    
}
